package com.ming.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.ming.dao.OrderSettingListDao;
import com.ming.entity.PageResult;
import com.ming.entity.QueryPageBean;
import com.ming.pojo.OrderSetting;
import com.ming.service.OrderSettingListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author NamingCao
 * @date 2021/07/12
 */

@Service(interfaceClass = OrderSettingListService.class)
@Transactional
public class OrderSettingListServiceImpl implements OrderSettingListService {

    @Autowired
    private OrderSettingListDao orderSettingListDao;

    public PageResult findPage(QueryPageBean queryPageBean) {Integer currentPage = queryPageBean.getCurrentPage();
        Integer pageSize = queryPageBean.getPageSize();
        //ThreadLocal
        String queryString = queryPageBean.getQueryString();
        //分页插件，会在执行sql之前将分页关键字追加到SQL后面
        PageHelper.startPage(currentPage,pageSize);
        Page<OrderSetting> page = orderSettingListDao.findByCondition(queryString);
        return new PageResult(page.getTotal(),page.getResult());
    }

}
